<template>
	<view class="container">
		<mescroll-body ref="mescrollRef" :top="listTop" :down="downOption" :up="upOption" @init="mescrollInit" @down="downCallback"
		 @up="upCallback">
			<view class="row" v-for="(item,index) in cashList" :key="index" v-if="cashList.length > 0">
				<view class="cach-info">
					<view class="cach-item">
						<text class="cach-name">提现 {{item.price}}</text>
						<text class="cach-time">申请时间：{{item.created_at}}</text>
						<text class="cach-time" v-if="item.pay_time != 0">打款时间：{{item.pay_time}}</text>
					</view>
					<view class="cach-status">
						<text class="status-text">{{item.pay_status}}</text>
					</view>
				</view>
			</view>
		</mescroll-body>

	</view>
</template>

<script>
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
	export default {
		mixins: [MescrollMixin],
		data() {
			return {
				cashList: [],
				downOption: {
					auto: true
				},
				upOption: {
					auto: false,
					page: {
						num: 0,
						size: 20
					},
					noMoreSize: 4,
					empty: {
						tip: '~ 空空如也 ~', // 提示
					}
				},
			}
		},
		onLoad() {

		},
		methods: {
			downCallback() {
				this.mescroll.resetUpScroll();
			},
			upCallback(page) {
				this.$http.get('api/user/cash-list', {
					params: {
						page: page.num
					}
				}).then((res) => {
					if (page.num == 1) this.cashList = [];
					let hasNext = true;
					if (!("list" in res) || res.length < 20) {
						hasNext = false;
					}
					this.mescroll.endSuccess(res.length, hasNext);
					res.forEach((item) => {
						this.cashList.push(item)
					})
				}).catch((error) => {
					this.mescroll.endErr();
				});
			},
		}
	}
</script>

<style>
	.container {
		padding: 0 20rpx;
	}

	.row {
		min-height: 120rpx;
		padding: 10rpx 20rpx;
		border-radius: 10rpx;
		background-color: #fff;
		margin-top: 20rpx;
		display: flex;
		flex-direction: column;
	}

	.cach-info {
		display: flex;
		flex-direction: row;
		align-items: center;
		padding: 20rpx 10rpx;
	}

	.cach-item {
		flex: 1;
		display: flex;
		flex-direction: column;
	}

	.cach-name {
		height: 44rpx;
		line-height: 44rpx;
		font-size: 28rpx;
		lines: 1;
		text-overflow: ellipsis;
	}

	.cach-time {
		height: 44rpx;
		line-height: 44rpx;
		font-size: 20rpx;
		color: #666;
	}

	.cach-status {
		line-height: 88rpx;
		align-items: center;
	}

	.status-text {
		line-height: 88rpx;
		font-size: 24rpx;
		color: #0081FF;
		text-align: right;
	}
</style>
